<template>
  <div>
    <!-- 默认简化写法prevent阻止事件默认行为 -->
    <a href="http://baidu.com" @click.prevent>去百度</a>
    <hr />
    <div class="father" @click="fn1">
      <!-- 阻止事件冒泡，固定写法 -->
      <div class="son" @click.stop="fn2"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: "JJ",
  components: {},
  props: {},
  data() {
    return {};
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    fn1() {
      console.log("我被点击了");
    },
    fn2() {
      console.log("我被入侵了");
    },
  },
};
</script>

<style scoped>
.son {
  width: 100px;
  height: 100px;
  background: pink;
}
.father {
  padding: 30px;
  background-color: blue;
  float: left;
}
</style>
